<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('openid')->unique()->comment('openid');
            $table->integer('fromid')->comment('推荐人')->default(0);
            $table->integer('ancestorid')->comment('推荐人的推荐人')->default(0);
            $table->string('name')->comment('昵称')->nullable();
            $table->string('avatar')->comment('头像地址')->nullable();
            $table->tinyInteger('gender')->comment('性别')->nullable();
            $table->string('city')->comment('所在城市')->nullable();
            $table->string('session_key')->comment('小程序sessionKey')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
